how to write code for tic tac toe game